#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int t,n,a[N],b[N],st[2],ans;
void dfs(int x){
    if(x>n){
        int res=0;
        for(int i=1;i<=n;++i){
            if(a[i]==st[b[i]])res+=a[i];
            st[b[i]]=a[i];
        }ans=max(ans,res);
        st[0]=st[1]=0;
        return;
    }b[x]=1,dfs(x+1);
    b[x]=0,dfs(x+1);
}
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n;
        if(n<=15){
            for(int i=1;i<=n;++i)
                cin>>a[i];
            dfs(1);cout<<ans<<'\n';
            ans=0;
        }
        
    }
    return 0;
}